import request from "../../../utils/request";
import { service } from "../index";

// 查询信息
export function queryIndustryViewRel(query) {
  return request({
    url: `${service}${
      query.isLocal
        ? "/localization/conf/querySysIndustryVerConfPage"
        : "/industry/rel/queryIndustryViewRel"
    } `,
    method: "post",
    data: query,
  });
}

//更新信息
export function updateIndustryViewRel(query) {
  return request({
    url: service + "/industry/rel/updateIndustryViewRel",
    method: "post",
    data: query,
  });
}

//更新信息
export function updateIndustryConf4IntfConf(query) {
  return request({
    url: service + "/industry/conf/updateIndustryConf4IntfConf",
    method: "post",
    data: query,
  });
}

export function queryIntfConfig(query) {
  return request({
    url: service + "/industry/rel/queryIntfConfig",
    method: "post",
    data: query,
  });
}

export function queryIntfConfigByIndustryId(query) {
  return request({
    url: service + "/industry/rel/queryIntfConfigByIndustryId",
    method: "post",
    data: query,
  });
}

//获取appKey和secretKey
export function getAppKey() {
  return request({
    url: service + "/industry/conf/getAppKey",
    method: "post",
  });
}

export function queryApiInterfaceMangeInfo(query) {
  return request({
    url: service + "/apiIntfMange/queryApiInterfaceMangeInfo",
    method: "post",
    data: query,
  });
}

// 信息操作
export function toUse(query) {
  return request({
    url: service + "/industry/rel/toUse",
    method: "post",
    data: query,
  });
}

/**
 * 将行业关联关系设置为未使用
 *
 * @param query 请求参数
 * @returns Promise
 */
export function toUnUse(query) {
  return request({
    url: service + "/industry/rel/toUnUse",
    method: "post",
    data: query,
  });
}

/**
 * 删除行业视图关联
 *
 * @param query 查询参数
 * @returns Promise
 */
export function delIndustryViewRel(query) {
  return request({
    url: `${service}${
      query.isLocal
        ? "/localization/conf/deleteSysIndustryVerConf"
        : "/industry/rel/delIndustryViewRel"
    } `,
    method: "post",
    data: query,
  });
}
// 查看详情展示
export function queryMenus(query) {
  return request({
    url: service + "/industry/rel/queryMenus",
    method: "post",
    data: query,
  });
}
// 初始化数据
export function queryIndustryConf(query) {
  return request({
    url: `${service}${
      query.isLocal
        ? "/localization/conf/querySysIndustryConfPage"
        : "/industry/conf/queryIndustryConf"
    }`,
    method: "post",
    data: query,
  });
}

/**
 * 查询视图模板
 *
 * @param query 查询参数
 * @returns 返回请求结果
 */
export function queryViewTemplate(query) {
  return request({
    url: service + "/industry/compo/queryViewTemplate",
    method: "post",
    data: query,
  });
}

/**
 * 查询系统行业配置详情
 *
 * @param data 请求数据
 * @returns 返回查询结果
 */
export function querySysIndustryConfDetail(data) {
  return data.isLocal
    ? request({
        url: service + `/localization/conf/querySysIndustryConfDetail`,
        method: "post",
        data,
      })
    : request({
        url: `${service}/industry/conf/querySysIndustryConfDetail`,
        method: "post",
        data,
      });
}

/**
 * 添加行业视图关联
 *
 * @param query 查询参数
 * @returns 请求结果
 */
export function addIndustryViewRel(query) {
  return request({
    url: service + "/industry/rel/addIndustryViewRel",
    method: "post",
    data: query,
  });
}

/**
 * 修改行业配置
 *
 * @param query 查询参数
 * @returns 修改结果
 */
export function modifyIndustryConf(query) {
  return request({
    url: `${service}${
      query.isLocal
        ? "/localization/conf/addOrEditSysIndustryConf"
        : "/industry/conf/modifyIndustryConf"
    }`,
    method: "post",
    data: query,
  });
}

/**
 * 添加行业配置
 *
 * @param query 查询参数
 * @returns Promise
 */
export function addIndustryConf(query) {
  return request({
    url: `${service}${
      query.isLocal
        ? "/localization/conf/addOrEditSysIndustryConf"
        : "/industry/conf/addIndustryConf"
    }`,
    method: "post",
    data: query,
  });
}
// 删除数据
export function delIndustryConf(query) {
  return request({
    url: `${service}${
      query.isLocal
        ? "/localization/conf/deleteSysIndustryConf"
        : "/industry/conf/delIndustryConf"
    }`,
    method: "post",
    data: query,
  });
}
// 查询行业应用版本
export function queryIndustryVerConf(query) {
  return request({
    url: service + "/industry/conf/queryIndustryVerConf",
    method: "post",
    data: query,
  });
}

// 节点树
export function platformDataConfigList(query = {}) {
  return request({
    url: service + "/localization/conf/platformDataConfigList",
    method: "post",
    data: query,
  });
}

// 属地应用配置状态变更
export function editSysIndustryConfStatus(query) {
  return request({
    url: service + "/localization/conf/editSysIndustryConfStatus",
    method: "post",
    data: query,
  });
}

// 属地应用配置版本变更
export function editSysIndustryVerConfStatus(query) {
  return request({
    url: service + "/localization/conf/editSysIndustryVerConfStatus",
    method: "post",
    data: query,
  });
}

// 属地应用配置下发
export function localizationDistributeConf(query) {
  return request({
    url: service + "/localization/conf/localizationDistributeConf",
    method: "post",
    data: query,
  });
}

// 属地应用版本下发
export function localizationDistributeVerConf(query) {
  return request({
    url: service + "/localization/conf/localizationDistributeVerConf",
    method: "post",
    data: query,
  });
}

// 属地应用版本提交
export function addOrEditSysIndustryVerConf(query) {
  return request({
    url: service + "/localization/conf/addOrEditSysIndustryVerConf",
    method: "post",
    data: query,
  });
}

/**
 * 查询行业列表
 * @param {*} data { pageName } 行业名称模糊查询
 */
export function queryIndustryList(data) {
  return request({
    url: "/ttmanage/screenConfig/queryScreenPageTree",
    method: "post",
    data,
  });
}

/**
 * 删除行业
 * @param {*} data { pageId } 行业id
 */
export function deleteIndustry(data) {
  return request({
    url: "/ttmanage/industryTypeConf/deleteIndustry",
    method: "post",
    data,
  });
}

/**
 * 行业管理
 * @param {*} data 新的行业列表
 */
export function updateIndustryList(data) {
  return request({
    url: "/ttmanage/industryTypeConf/addOrUpdateTypeConf",
    method: "post",
    data,
  });
}

/**
 * 查询所属行业
 */
export function getIndustryTypeConf(query) {
  return request({
    url: "/ttmanage/industryTypeConf/getList",
    method: "get",
    data: query,
  });
}
